Skip to content

Conversation

@zeroshade
Copy link
Member

When using dbc auth login to login to the Columnar private registry, we'll check the token and see if it contains the trial_start claim, downloading the license if it exists.

There's some more work that needs to happen here so I'm leaving this marked as WIP, such as:

  • Picking a domain for the cloudflare workers
  • making the worker domain configurable via env var
  • unit tests
  • verifying this workflow makes sense

@ianmcook
Copy link
Member

Nice! Let's also please make it so that if the user runs dbc install or dbc sync to install a private driver, dbc checks to see whether:

  1. the user is authenticated
  2. the user has an active trial license
  3. the user has not yet downloaded columnar.lic and put it in the required location.

If all three of those things are true, dbc should download columnar.lic and put it in the required location for the user.

@zeroshade zeroshade changed the title WIP: feat(auth): automatically fetch Columnar license on login feat(auth): automatically fetch Columnar license on login Dec 12, 2025
@zeroshade
Copy link
Member Author

@ianmcook updated per your suggestion

@zeroshade zeroshade requested a review from lidavidm December 12, 2025 21:25
@zeroshade
Copy link
Member Author

Added @lidavidm so he can see where dbc is putting the license

@ianmcook
Copy link
Member

@ianmcook updated per your suggestion

Nice! I tested it successfully.

Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you log in and your trial is expired, you don't get any feedback:

$ dlv debug --headless ./cmd/dbc -- auth login
API server listening at: 127.0.0.1:39367
Opening https://auth.columnar.tech/activate?user_code=QVLR-GDCV in your default web browser...
Gtk-Message: 13:10:44.101: Not loading module "atk-bridge": The functionality is provided by GTK natively. Please try to not load it.
Authentication successful!

In dlv, I can see that I got a 403:

> github.com/columnar-tech/dbc/auth.FetchColumnarLicense() ./auth/credentials.go:318 (PC: 0x978c8a)
   313:		if err != nil {
   314:			return err
   315:		}
   316:		defer resp.Body.Close()
   317:	
=> 318:		if resp.StatusCode != http.StatusOK {
   319:			return fmt.Errorf("failed to fetch license: %s", resp.Status)
   320:		}
   321:	
   322:		licenseFile, err := os.OpenFile(licensePath, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0o600)
   323:		if err != nil {
(dlv) p resp.StatusCode
403

But this is not reported in the UI.

@amoeba
Copy link
Member

amoeba commented Dec 24, 2025

I'm not sure if this is the same error as @lidavidm got but here's what I did:

  1. Ran go run ./cmd/dbc auth login
  2. In my browser, saw the user code, clicked Confirm
  3. Logged in to Columnar with Google
  4. Got to my account details page (https://cloud.columnar.tech/account)

Back in my terminal, the CLI is stuck on

Authentication successful!
⠙ Waiting for confirmation...

I note that my trial is expired. Also I notice that the text says

Expires: Thu, 25 Dec 2025 23:16:09 GMT

but it should probably tell me that my license is expired.

@zeroshade
Copy link
Member Author

@amoeba can you try again? It looks good to me (and I'll update the website to be more explicit when the trial is expired)

@amoeba
Copy link
Member

amoeba commented Jan 11, 2026

Thanks @zeroshade. I can't reproduce anymore as I don't have an expired license but dbc auth login works fine now.

var cmd tea.Cmd
switch {
case errors.Is(msg, auth.ErrTrialExpired):
cmd = tea.Println(errStyle.Render("Could not download license, trial has expired"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set non-zero status? I'm not totally sure if we should or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal opinion is that we don't need a non-zero status for the trial handling because I don't want dbc to always fail if they login but haven't started the trial yet etc.

Copy link
Member Author

@zeroshade zeroshade Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, after discussing with @ianmcook we decided that this will give a non-zero status, but it won't error/give a non-zero status during dbc auth login. It'll only error during install/sync

I've updated this accordingly

@amoeba
Copy link
Member

amoeba commented Jan 12, 2026

I ran into an issue while testing driver list support for this,

$ go run ./cmd/dbc info red-o
Driver: red-o
Version: 0.3.0
Title: Columnar ADBC Driver red-o
License: LicenseRef-PBL
Description: An ADBC driver for Oracle Database developed by Columnar
Available Packages:
   - linux_amd64
   - linux_arm64
   - macos_arm64
   - windows_amd64
   
~/src/columnar-tech/dbc auth-fetch-license
$ go run ./cmd/dbc init

~/src/columnar-tech/dbc auth-fetch-license
$ go run ./cmd/dbc add red-o
added red-o to driver list
use `dbc sync` to install the drivers in the list

~/src/columnar-tech/dbc auth-fetch-license
$ go run ./cmd/dbc sync
Error: failed to download driver: failed to download driver https://dbc-cdn-private.columnar.tech/red-o/v0.3.0/red-o_macos_arm64_v0.3.0.tar.gz: 401 Unauthorized
exit status 1

This was go running from 7a4e818e9e20269d133df301dbfa9cf63d2c1de7.

@amoeba
Copy link
Member

amoeba commented Jan 13, 2026

I ran dbc auth login and it worked after I did that. I can't remember how I got the token that 401's but, looking at it decoded, the biggest difference is that,

  • The token that 401s had "permissions":[]
  • The token that worked fine had "permissions":["access:index","access:red-o"]

Otherwise things looked structurally similar.

@zeroshade
Copy link
Member Author

sigh yea, looks like I might have to do part of what I was discussing with Ian. I was trying to reduce calls and latency but I guess there's no way around it. I'll do some stuff tomorrow to make this more robust and handle things better instead of relying on the (potentially stale) login token

@zeroshade
Copy link
Member Author

@amoeba Okay, I've updated the lambda func to fallback and make a call to heimdall.columnar.tech for the latest token when the token came from Auth0 and doesn't contain the appropriate permissions. This will cover the scenario you had where you had to re-login.

@amoeba
Copy link
Member

amoeba commented Jan 17, 2026

Nice! Let me test that out in a sec and I'll report back.

@amoeba
Copy link
Member

amoeba commented Jan 17, 2026

I wasn't able to get this to work how I expected. I deleted my account in auth0, signed up with a fresh account, logged in but did not start my trial, ran dbc auth login, started my trial, and ran dbc install oracle. It hung for a good 5-10 seconds and then error'd with,

$ go run ./cmd/dbc install oracle
Error: failed to download driver https://dbc-cdn-private.columnar.tech/oracle/v0.4.0/oracle_macos_arm64_v0.4.0.tar.gz: 401 Unauthorized
exit status 1

@amoeba
Copy link
Member

amoeba commented Jan 17, 2026

I had mitmproxy running dbc made two requests (amongst others) to install the driver. The first 401 had a JWT with "permissions":[] as expected. The second 401 had "permissions":["access:index","access:red-o"]}

@amoeba
Copy link
Member

amoeba commented Jan 17, 2026

Maybe something else is going on. I went back to the preview Cloud site and the UI didn't show I had a trial. I then tried to restart my trial and it kept failing after I hit Accept with a 400 "Trial already started" in the console. I'll file a bug since the registry site needs to handle that.

@zeroshade zeroshade merged commit 656e7da into main Jan 17, 2026
13 of 14 checks passed
@zeroshade zeroshade deleted the auth-fetch-license branch January 17, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants